home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15223 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.0 KB

  1. Path: rubens.telebyte.nl!news
  2. From: Christ van Willegen <cvw@spc.nl>
  3. Newsgroups: comp.lang.c++
  4. Subject: Writing AVI problems
  5. Date: Thu, 04 Apr 1996 10:58:45 +0100
  6. Organization: SPC Vision b.v.
  7. Message-ID: <31639D55.2FCB@spc.nl>
  8. NNTP-Posting-Host: 193.67.232.34
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  13.  
  14. Hi,
  15.  
  16. First, let me introduce myself. I'm a programmer who works at a company
  17. that produces multi-media CD-ROM and CD-i titles.
  18.  
  19. I am currently busy writing a program that can generate an AVI file from
  20. a bunch of image files, and an audio file.
  21.  
  22. The video part works correctly, and I can write correct video streams.
  23. The problems start when I want to write the Audio and Video streams
  24. together.
  25.  
  26. THe program consists of two parts. In the first part, I construct a video
  27. stream from the external graphics files. In the second part, I re-open
  28. the video stream I just created, open the audio file (standard .WAV file)
  29. and open a new AVI file, with a video and an audio stream.
  30.  
  31. Then, I read the Video and Audio data in a loop, and write the data to the
  32. two new streams. The loop looks like this. I hope the variable names are
  33. clear enough:
  34.  
  35.         Raw=(unsigned char *)malloc(200*1024);
  36.  
  37.         // Then, read data from the audio and video streams
  38.         // opened above (AVIStreamRead)
  39.         // Write the multi-media data to the new AVI file (AVIStreamWrite)
  40.  
  41.         Sample=0;            
  42.         AudioSample=0;
  43.         BytesWritten=0;
  44.  
  45.         do
  46.         {
  47.             hr=AVIStreamRead (pvs, Sample, 1, Raw, 200*1024,
  48.                     &BytesRead, &SamplesRead);
  49.             hr=AVIStreamWrite(pvs2,Sample, SamplesRead, Raw, 200*1024,
  50.             (Sample%KeyFrames)?0:AVIIF_KEYFRAME, &SamplesWritten, &BytesWritten);
  51.  
  52.             hr=AVIStreamRead (pas, AudioSample, SamplesRead*
  53.                         pFormat->nSamplesPerSec/(Scripting?10:Fps)/pFormat->nBlockAlign,
  54.             Raw, 200*1024, &BytesRead, &AudioSamplesRead);
  55.             hr=AVIStreamWrite(pas2,AudioSample, AudioSamplesRead, Raw, 200*1024,
  56.             AVIIF_KEYFRAME, &AudioSamplesWritten, &BytesWritten);
  57.  
  58.             Sample+=SamplesRead;
  59.             AudioSample+=AudioSamplesRead;
  60.  
  61.         } while (SamplesRead);
  62.  
  63.         // Close the files!
  64.  
  65. Raw is a buffer to hold the data;
  66. Sample is the video sample I'm at
  67. AudioSample is the audio sample I'm at
  68. KeyFrames is the 'distance' between two keyframes
  69. Scripting tells me if I'm using a script file for writing the AVI file. If so, I'm using
  70.   10 Fps, else the value in Fps
  71. Pas and Pas2 are pointers to audio streams.
  72. Pvs and Pvs2 are pointers to video stream.
  73.  
  74. The 'hr' variable is (clearly) there for debugging purposes.
  75. After both AVIStreamWrite()'s, hr equals the value 0x8000ffff, which is an undocumented
  76. error (Error = 0xbfff). The value of BytesWritten never changes!
  77.  
  78. Afterwards, the resulting AVI file has 1 video stream, with the correct data, and no
  79. audio streams.
  80.  
  81. If anyone can shed some light on this problem, that would help me a lot! I can mail/post
  82. more source if that's needed.
  83.  
  84. Please e-mail to me, and I'll summarise in the group, as I usually don't read it.
  85.  
  86. Thanks in advance!
  87.  
  88. Christ van Willegen
  89.